package com.guaoran.newsdata.api.service;

import com.guaoran.newsdata.api.domain.News;
import com.guaoran.newsdata.api.hystrix.NewsDataCoreServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;

/**
 * @Author gucheng
 * @Description
 * {@link News} 服务
 *  请求连接需要对应服务提供方的链接
 * 2019-03-29 12:21
 */
@FeignClient(value = "news-data-service-provider",fallback = NewsDataCoreServiceFallback.class)
public interface NewsDataCoreService {

    /**
     * 保存
     * @param news {@link News}
     * @return 如果成功，<code>true</code>
     */
    @PostMapping(value = "/news/save")
    boolean save(@RequestBody News news);
    /**
     * 修改
     * @param news {@link News}
     * @return 如果成功，<code>true</code>
     */
    @PutMapping(value = "/news/update")
    boolean update(@RequestBody News news);
    /**
     * 删除
     * @param id
     * @return 如果成功，<code>true</code>
     */
    @DeleteMapping(value = "/news/delete/{id}")
    boolean delete(@PathVariable("id") Long id);
    /**
     * 查询所有新闻
     * @return
     */
    // 对应的是 要调用客户端的请求地址
    @GetMapping("/news/list")
    Collection<News> findAll();

    /**
     * 查询新闻
     * @param id
     * @return
     */
    @GetMapping("/news/find/{id}")
    News findById(@PathVariable("id") Long id);
}
